package com.test.designmode.decorator;

public class  RedShapeDecorator extends ShapeDecorator {

    //构造器初始化 装饰器的同时也初始化了目标对象
    public RedShapeDecorator(Shape decoratedShape) {
        //调用父类的构造方法
        super(decoratedShape);
        //子类构造器执行时会先调用-父类构造器，这里只能写在super方法后面,
        System.out.println("init 装饰器子类构造器");
    }

    //实现类的子类 可以重写父类的Override方法，这样父类的Override方法就不会执行了
    @Override
    public void draw() {
        System.out.println("调用目标接口的draw方法");
        decoratedShape.draw();
        //调用附加的装饰方法
        setRedBorder(decoratedShape);
    }

    //附加的装饰方法
    private void setRedBorder(Shape decoratedShape){
        System.out.println("装饰器子类调用附加的装饰方法");
        System.out.println("Border Color: Red");
    }
}